package com.itheima.mapper;

import com.itheima.pojo.WarehousingEntryDetails;
import org.apache.ibatis.jdbc.SQL;

import java.util.List;

public class WarehousingEntryDetailsSqlProvider {

    public String insertBatchSomeColumn(List<WarehousingEntryDetails> detailsList) {
        StringBuilder sql = new StringBuilder();
        sql.append("INSERT INTO tb_warehousing_entry_details ");
        sql.append("(sku_id, count, supplier_id, price, warehousing_entry_id, predicted_arrival_time, status, create_time, is_del) VALUES ");

        for (int i = 0; i < detailsList.size(); i++) {
            if (i > 0) sql.append(",");
            sql.append("(#{list[").append(i).append("].skuId}, ")
                    .append("#{list[").append(i).append("].count}, ")
                    .append("#{list[").append(i).append("].supplierId}, ")
                    .append("#{list[").append(i).append("].price}, ")
                    .append("#{list[").append(i).append("].warehousingEntryId}, ")
                    .append("#{list[").append(i).append("].predictedArrivalTime}, ")
                    .append("#{list[").append(i).append("].status}, ")
                    .append("#{list[").append(i).append("].createTime}, ")
                    .append("#{list[").append(i).append("].isDel})");
        }

        return sql.toString();
    }
}
